/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package model.impl;

import java.util.Collection;
import model.Actor;
import model.ActorsPackage;
import model.Association;
import model.Episode;
import model.EpisodesPackage;
import model.ModelPackage;
import model.Role;
import model.Season;
import model.SeasonPackage;
import model.Serie;
import model.SeriesPackage;
import model.Workspace;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Workspace</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link model.impl.WorkspaceImpl#getGroupOfSeries <em>Group Of Series</em>}</li>
 *   <li>{@link model.impl.WorkspaceImpl#getGroupOfActors <em>Group Of Actors</em>}</li>
 *   <li>{@link model.impl.WorkspaceImpl#getAssociations <em>Associations</em>}</li>
 *   <li>{@link model.impl.WorkspaceImpl#getRoles <em>Roles</em>}</li>
 *   <li>{@link model.impl.WorkspaceImpl#getSeasons <em>Seasons</em>}</li>
 *   <li>{@link model.impl.WorkspaceImpl#getSeries <em>Series</em>}</li>
 *   <li>{@link model.impl.WorkspaceImpl#getEpisodes <em>Episodes</em>}</li>
 *   <li>{@link model.impl.WorkspaceImpl#getActors <em>Actors</em>}</li>
 *   <li>{@link model.impl.WorkspaceImpl#getEpisodesPackage <em>Episodes Package</em>}</li>
 *   <li>{@link model.impl.WorkspaceImpl#getSeasonsPackage <em>Seasons Package</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class WorkspaceImpl extends EObjectImpl implements Workspace {
	/**
	 * The cached value of the '{@link #getGroupOfSeries() <em>Group Of Series</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGroupOfSeries()
	 * @generated
	 * @ordered
	 */
	protected SeriesPackage groupOfSeries;

	/**
	 * The cached value of the '{@link #getGroupOfActors() <em>Group Of Actors</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGroupOfActors()
	 * @generated
	 * @ordered
	 */
	protected ActorsPackage groupOfActors;

	/**
	 * The cached value of the '{@link #getAssociations() <em>Associations</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAssociations()
	 * @generated
	 * @ordered
	 */
	protected EList<Association> associations;

	/**
	 * The cached value of the '{@link #getRoles() <em>Roles</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRoles()
	 * @generated
	 * @ordered
	 */
	protected EList<Role> roles;

	/**
	 * The cached value of the '{@link #getSeasons() <em>Seasons</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSeasons()
	 * @generated
	 * @ordered
	 */
	protected EList<Season> seasons;

	/**
	 * The cached value of the '{@link #getSeries() <em>Series</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSeries()
	 * @generated
	 * @ordered
	 */
	protected EList<Serie> series;

	/**
	 * The cached value of the '{@link #getEpisodes() <em>Episodes</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEpisodes()
	 * @generated
	 * @ordered
	 */
	protected EList<Episode> episodes;

	/**
	 * The cached value of the '{@link #getActors() <em>Actors</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getActors()
	 * @generated
	 * @ordered
	 */
	protected EList<Actor> actors;

	/**
	 * The cached value of the '{@link #getEpisodesPackage() <em>Episodes Package</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEpisodesPackage()
	 * @generated
	 * @ordered
	 */
	protected EList<EpisodesPackage> episodesPackage;

	/**
	 * The cached value of the '{@link #getSeasonsPackage() <em>Seasons Package</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSeasonsPackage()
	 * @generated
	 * @ordered
	 */
	protected EList<SeasonPackage> seasonsPackage;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected WorkspaceImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ModelPackage.Literals.WORKSPACE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SeriesPackage getGroupOfSeries() {
		return groupOfSeries;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetGroupOfSeries(SeriesPackage newGroupOfSeries, NotificationChain msgs) {
		SeriesPackage oldGroupOfSeries = groupOfSeries;
		groupOfSeries = newGroupOfSeries;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelPackage.WORKSPACE__GROUP_OF_SERIES, oldGroupOfSeries, newGroupOfSeries);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setGroupOfSeries(SeriesPackage newGroupOfSeries) {
		if (newGroupOfSeries != groupOfSeries) {
			NotificationChain msgs = null;
			if (groupOfSeries != null)
				msgs = ((InternalEObject)groupOfSeries).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ModelPackage.WORKSPACE__GROUP_OF_SERIES, null, msgs);
			if (newGroupOfSeries != null)
				msgs = ((InternalEObject)newGroupOfSeries).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ModelPackage.WORKSPACE__GROUP_OF_SERIES, null, msgs);
			msgs = basicSetGroupOfSeries(newGroupOfSeries, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.WORKSPACE__GROUP_OF_SERIES, newGroupOfSeries, newGroupOfSeries));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ActorsPackage getGroupOfActors() {
		return groupOfActors;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetGroupOfActors(ActorsPackage newGroupOfActors, NotificationChain msgs) {
		ActorsPackage oldGroupOfActors = groupOfActors;
		groupOfActors = newGroupOfActors;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelPackage.WORKSPACE__GROUP_OF_ACTORS, oldGroupOfActors, newGroupOfActors);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setGroupOfActors(ActorsPackage newGroupOfActors) {
		if (newGroupOfActors != groupOfActors) {
			NotificationChain msgs = null;
			if (groupOfActors != null)
				msgs = ((InternalEObject)groupOfActors).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ModelPackage.WORKSPACE__GROUP_OF_ACTORS, null, msgs);
			if (newGroupOfActors != null)
				msgs = ((InternalEObject)newGroupOfActors).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ModelPackage.WORKSPACE__GROUP_OF_ACTORS, null, msgs);
			msgs = basicSetGroupOfActors(newGroupOfActors, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, ModelPackage.WORKSPACE__GROUP_OF_ACTORS, newGroupOfActors, newGroupOfActors));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Association> getAssociations() {
		if (associations == null) {
			associations = new EObjectContainmentEList<Association>(Association.class, this, ModelPackage.WORKSPACE__ASSOCIATIONS);
		}
		return associations;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Role> getRoles() {
		if (roles == null) {
			roles = new EObjectContainmentEList<Role>(Role.class, this, ModelPackage.WORKSPACE__ROLES);
		}
		return roles;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Season> getSeasons() {
		if (seasons == null) {
			seasons = new EObjectContainmentEList<Season>(Season.class, this, ModelPackage.WORKSPACE__SEASONS);
		}
		return seasons;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Serie> getSeries() {
		if (series == null) {
			series = new EObjectContainmentEList<Serie>(Serie.class, this, ModelPackage.WORKSPACE__SERIES);
		}
		return series;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Episode> getEpisodes() {
		if (episodes == null) {
			episodes = new EObjectContainmentEList<Episode>(Episode.class, this, ModelPackage.WORKSPACE__EPISODES);
		}
		return episodes;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Actor> getActors() {
		if (actors == null) {
			actors = new EObjectContainmentEList<Actor>(Actor.class, this, ModelPackage.WORKSPACE__ACTORS);
		}
		return actors;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<EpisodesPackage> getEpisodesPackage() {
		if (episodesPackage == null) {
			episodesPackage = new EObjectContainmentEList<EpisodesPackage>(EpisodesPackage.class, this, ModelPackage.WORKSPACE__EPISODES_PACKAGE);
		}
		return episodesPackage;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<SeasonPackage> getSeasonsPackage() {
		if (seasonsPackage == null) {
			seasonsPackage = new EObjectContainmentEList<SeasonPackage>(SeasonPackage.class, this, ModelPackage.WORKSPACE__SEASONS_PACKAGE);
		}
		return seasonsPackage;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ModelPackage.WORKSPACE__GROUP_OF_SERIES:
				return basicSetGroupOfSeries(null, msgs);
			case ModelPackage.WORKSPACE__GROUP_OF_ACTORS:
				return basicSetGroupOfActors(null, msgs);
			case ModelPackage.WORKSPACE__ASSOCIATIONS:
				return ((InternalEList<?>)getAssociations()).basicRemove(otherEnd, msgs);
			case ModelPackage.WORKSPACE__ROLES:
				return ((InternalEList<?>)getRoles()).basicRemove(otherEnd, msgs);
			case ModelPackage.WORKSPACE__SEASONS:
				return ((InternalEList<?>)getSeasons()).basicRemove(otherEnd, msgs);
			case ModelPackage.WORKSPACE__SERIES:
				return ((InternalEList<?>)getSeries()).basicRemove(otherEnd, msgs);
			case ModelPackage.WORKSPACE__EPISODES:
				return ((InternalEList<?>)getEpisodes()).basicRemove(otherEnd, msgs);
			case ModelPackage.WORKSPACE__ACTORS:
				return ((InternalEList<?>)getActors()).basicRemove(otherEnd, msgs);
			case ModelPackage.WORKSPACE__EPISODES_PACKAGE:
				return ((InternalEList<?>)getEpisodesPackage()).basicRemove(otherEnd, msgs);
			case ModelPackage.WORKSPACE__SEASONS_PACKAGE:
				return ((InternalEList<?>)getSeasonsPackage()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ModelPackage.WORKSPACE__GROUP_OF_SERIES:
				return getGroupOfSeries();
			case ModelPackage.WORKSPACE__GROUP_OF_ACTORS:
				return getGroupOfActors();
			case ModelPackage.WORKSPACE__ASSOCIATIONS:
				return getAssociations();
			case ModelPackage.WORKSPACE__ROLES:
				return getRoles();
			case ModelPackage.WORKSPACE__SEASONS:
				return getSeasons();
			case ModelPackage.WORKSPACE__SERIES:
				return getSeries();
			case ModelPackage.WORKSPACE__EPISODES:
				return getEpisodes();
			case ModelPackage.WORKSPACE__ACTORS:
				return getActors();
			case ModelPackage.WORKSPACE__EPISODES_PACKAGE:
				return getEpisodesPackage();
			case ModelPackage.WORKSPACE__SEASONS_PACKAGE:
				return getSeasonsPackage();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ModelPackage.WORKSPACE__GROUP_OF_SERIES:
				setGroupOfSeries((SeriesPackage)newValue);
				return;
			case ModelPackage.WORKSPACE__GROUP_OF_ACTORS:
				setGroupOfActors((ActorsPackage)newValue);
				return;
			case ModelPackage.WORKSPACE__ASSOCIATIONS:
				getAssociations().clear();
				getAssociations().addAll((Collection<? extends Association>)newValue);
				return;
			case ModelPackage.WORKSPACE__ROLES:
				getRoles().clear();
				getRoles().addAll((Collection<? extends Role>)newValue);
				return;
			case ModelPackage.WORKSPACE__SEASONS:
				getSeasons().clear();
				getSeasons().addAll((Collection<? extends Season>)newValue);
				return;
			case ModelPackage.WORKSPACE__SERIES:
				getSeries().clear();
				getSeries().addAll((Collection<? extends Serie>)newValue);
				return;
			case ModelPackage.WORKSPACE__EPISODES:
				getEpisodes().clear();
				getEpisodes().addAll((Collection<? extends Episode>)newValue);
				return;
			case ModelPackage.WORKSPACE__ACTORS:
				getActors().clear();
				getActors().addAll((Collection<? extends Actor>)newValue);
				return;
			case ModelPackage.WORKSPACE__EPISODES_PACKAGE:
				getEpisodesPackage().clear();
				getEpisodesPackage().addAll((Collection<? extends EpisodesPackage>)newValue);
				return;
			case ModelPackage.WORKSPACE__SEASONS_PACKAGE:
				getSeasonsPackage().clear();
				getSeasonsPackage().addAll((Collection<? extends SeasonPackage>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ModelPackage.WORKSPACE__GROUP_OF_SERIES:
				setGroupOfSeries((SeriesPackage)null);
				return;
			case ModelPackage.WORKSPACE__GROUP_OF_ACTORS:
				setGroupOfActors((ActorsPackage)null);
				return;
			case ModelPackage.WORKSPACE__ASSOCIATIONS:
				getAssociations().clear();
				return;
			case ModelPackage.WORKSPACE__ROLES:
				getRoles().clear();
				return;
			case ModelPackage.WORKSPACE__SEASONS:
				getSeasons().clear();
				return;
			case ModelPackage.WORKSPACE__SERIES:
				getSeries().clear();
				return;
			case ModelPackage.WORKSPACE__EPISODES:
				getEpisodes().clear();
				return;
			case ModelPackage.WORKSPACE__ACTORS:
				getActors().clear();
				return;
			case ModelPackage.WORKSPACE__EPISODES_PACKAGE:
				getEpisodesPackage().clear();
				return;
			case ModelPackage.WORKSPACE__SEASONS_PACKAGE:
				getSeasonsPackage().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ModelPackage.WORKSPACE__GROUP_OF_SERIES:
				return groupOfSeries != null;
			case ModelPackage.WORKSPACE__GROUP_OF_ACTORS:
				return groupOfActors != null;
			case ModelPackage.WORKSPACE__ASSOCIATIONS:
				return associations != null && !associations.isEmpty();
			case ModelPackage.WORKSPACE__ROLES:
				return roles != null && !roles.isEmpty();
			case ModelPackage.WORKSPACE__SEASONS:
				return seasons != null && !seasons.isEmpty();
			case ModelPackage.WORKSPACE__SERIES:
				return series != null && !series.isEmpty();
			case ModelPackage.WORKSPACE__EPISODES:
				return episodes != null && !episodes.isEmpty();
			case ModelPackage.WORKSPACE__ACTORS:
				return actors != null && !actors.isEmpty();
			case ModelPackage.WORKSPACE__EPISODES_PACKAGE:
				return episodesPackage != null && !episodesPackage.isEmpty();
			case ModelPackage.WORKSPACE__SEASONS_PACKAGE:
				return seasonsPackage != null && !seasonsPackage.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //WorkspaceImpl
